<?php
/**
 * 描述：行业展会-列表信息页。
 * @final
 */
final class Exec_Exhibition_Infos_List extends Exec_Exhibition_Right
{
    public function Get()
    {
        #获取参数
        $type=Functions::UrlArgs('type');

        #定义标量
        $params=array('type'=>$type);
        $contentTitle=NULL;
        $templatePath='exhibition/infos/list.tpl';

        #执行操作
        switch($type)
        {
            case 'inland':
                $contentTitle='国内展会';
                $data= DB::GetData('select * from exhibition_infos where ClassID='.DAO_ExhibitionClass::INLAND_ID.' order by ID desc limit ?,20');
            break;
            case 'international':
                $contentTitle='国际展会';
                $data=DB::GetData('select * from exhibition_infos where ClassID='.DAO_ExhibitionClass::INTERNATIONAL_ID.' order by ID desc limit ?,20');
            break;
            case 'cooperation':
                $contentTitle='合作展会';
                $data=DB::GetData('select * from exhibition_infos where M_IsCooperation=TRUE order by ID desc limit ?,20');
            break;
            case 'search':
                $contentTitle='展会搜索';
                $year=trim(Functions::UrlArgs('year'));
                $month=trim(Functions::UrlArgs('month'));
                $place=trim(Functions::UrlArgs('place'));
                $title=trim(Functions::UrlArgs('title'));
                
                #制作SQL及参数
                $sqlParams=array();
                $sql='select * from exhibition_infos where 1=1 ';
                {
                    if($year)
                    {
                        $sql=$sql.'and year(StartDatetime)=? ';
                        $sqlParams[]=$year;
                        $params['year']=$year;
                    }

                    if($month)
                    {
                        $sql=$sql.'and month(StartDatetime)=? ';
                        $sqlParams[]=$month;
                        $params['month']=$month;
                    }

                    if($place)
                    {
                        $sql=$sql.'and place=? ';
                        $sqlParams[]=$place;
                        $params['place']=urldecode($place);
                    }

                    if($title)
                    {
                        $sql=$sql.'and title like ? ';
                        $sqlParams[]='%'.$title.'%';
                        $params['title']=urlencode($title);
                    }                                        
                }
                $sql.='order by ID desc limit ?,20';
                //print_r($sqlParams);
                //echo'<br/>'.$sql;
                //exit();
                $data=DB::PGetData($sql,$sqlParams);
            break;
            default:
                header("HTTP/1.0 404 Not Found");
                return;
            break;
        }

        #渲染模板
        View::Assign('Exhibition_List_ContentTitle',$contentTitle);
        View::Assign('Exhibition_List_Infos',$data['Record']);
        View::Assign('Exhibition_List_PageMenu',PagerFactory::Create('Common')->Fetch($data,array
        (
            'URL'=>'/exec.php?action=exhibition_infos_list',
            'IsDetail'=>TRUE,
            'Parameters'=>$params,
            'Rewriter'=>($type=='search') ? NULL:new PagerRewrite('/'.$type.'/','','html')
        )));
        View::Display($templatePath);
    }
}
?>